﻿using DocumentFormat.OpenXml.Lite.Core.Office;
using DocumentFormat.OpenXml.Lite.WordprocessingML.Word.Base;
using S = DocumentFormat.OpenXml.Lite.WordprocessingML.Word.Style;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WRP = DocumentFormat.OpenXml.Lite.WordprocessingML.Word.RunProperties;
using WPP = DocumentFormat.OpenXml.Lite.WordprocessingML.Word.ParagraphProperties;

namespace Samples.Word
{
    class Styles
    {
        public static void Create()
        {
            Document doc = DocumentManager.Instance.CreateWordDocument();

            S.Styles styles = doc.CreateStyle();
            styles.DocumentDefaults = new S.DefaultStyles();

            styles.DocumentDefaults.AddRunProperty(new WRP.FontSize() { Size = 24 });
            styles.DocumentDefaults.AddRunProperty(new WRP.Fonts { AsciiFont = "Times New Roman" });

            styles.DocumentDefaults.AddParagraphProperty(new WPP.Spacing() { After = 0 });

            doc.CreateBody().AddParagraph().AddRun().AddSimpleText("Hello world!");
            doc.Body.AddParagraph().AddRun().AddSimpleText("Second row.");

            doc.Save(@"samples\styles.docx");

            Document parsed = null;
            if (DocumentManager.Instance.OpenWordDocument(@"samples\styles.docx", out parsed))
            {
                Console.WriteLine("Sample created and parsed succesfully!");
            }
            Console.ReadLine();
        }
    }
}
